#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
#include<utility>
using namespace std;

#define double long double
#define int long long

int T;
int n,m,l,v;
bool case0,case1,case2,case3;

struct Car{
    double d,v,a,l,r;
}a[100010];
double b[100010];

double s(double v0,double t,double a){
    return v0*t+0.5*a*t*t;
}
double sp(double v0,double s,double a){
    double t=2.0*a*s+v0*v0;
    if(t<=0.0)return 0.0;
    return sqrt(t);
}

vector<pair<int,int> >vcase0;
void dfscase0(int p,int nows){
    if(p>m){
        int s=0,num=0;bool vis[30];memset(vis,0,sizeof(vis));
        for(int i=0;i<m;++i){
            if((nows>>i)&1){
                num++;
                for(int j=1;j<=n;++j){
                    if(a[j].l<=b[i+1]&&a[j].r>=b[i+1]){
                        vis[j]=1;
                    }
                }
            }
        }
        for(int i=1;i<=n;++i){
            s=(s<<1)|vis[i];
        }
        vcase0.push_back(make_pair(num,s));
        return ;
    }
    dfscase0(p+1,(nows<<1)|1);
    dfscase0(p+1,(nows<<1));
}

void clear(){
    vcase0.clear();
    case0=0;case1=case2=case3=1;
}
void solve(){
    cin>>n>>m>>l>>v;
    if(n<=20&&m<=20){
        case0=1;
    }
    for(int i=1;i<=n;++i){
        cin>>a[i].d>>a[i].v>>a[i].a;
        if(a[i].a!=0){
            case1=0;
        }
        if(a[i].a>0){
            case3=0;
        }
        if(a[i].a<0){
            case2=0;
        }
        if(a[i].a>=0.0){
            double L=a[i].d,R=l;
            for(int time=1;time<=100;++time){
                double mid=(L+R)/2.0;
                if(sp(a[i].v,mid-a[i].d,a[i].a)>v){
                    R=mid;
                }
                else{
                    L=mid;
                }
            }
            if(L+0.1>=R){
                if(sp(a[i].v,R,a[i].a)>v+0.000000001){
                    L=R;
                }
                else{
                    L=R+1.0;
                }
            }
            a[i].l=R+0.000000001;
            a[i].r=l;
        }
        else{
            double L=a[i].d,R=l;
            for(int time=1;time<=100;++time){
                double mid=(L+R)/2.0;
                if(sp(a[i].v,mid-a[i].d,a[i].a)>v){
                    L=mid;
                }
                else{
                    R=mid;
                }
            }
            if(L+0.1>=R){
                if(sp(a[i].v,R,a[i].a)>v+0.000000001){
                    L=R;
                }
                else{
                    L=R+1.0;
                }
            }
            a[i].l=a[i].d;
            a[i].r=R+0.000000001;
        }
        //printf("%.5lf,%.5lf\n",a[i].l,a[i].r);
    }
    for(int i=1;i<=m;++i){
        cin>>b[i];
    }
    sort(b+1,b+1+m);
    if(case0){
        int ans=0;
        bool vis[30];memset(vis,0,sizeof(vis));
        int tgt=0;
        for(int i=1;i<=m;++i){
            for(int j=1;j<=n;++j){
                if(a[j].l<=b[i]&&a[j].r>=b[i]){
                    vis[j]=1;
                }
            }
        }
        for(int i=1;i<=n;++i){
            ans+=vis[i];
            tgt=(tgt<<1)|vis[i];
        }
        cout<<ans<<" ";
        dfscase0(1,0);
        ans=1e9;
        for(int i=0;i<vcase0.size();++i){
            //cout<<vcase0[i].second<<' ';
            if(vcase0[i].second==tgt){
                ans=min(ans,vcase0[i].first);
            }
        }
        cout<<m-ans<<"\n";
    }
    else if(case1||case2){
        int ans=0;
        bool vis[30];memset(vis,0,sizeof(vis));
        for(int j=1;j<=n;++j){
            if(a[j].l<=b[m]&&a[j].r>=b[m]){
                vis[j]=1;
            }
        }
        for(int i=1;i<=n;++i){
            ans+=vis[i];
        }
        cout<<ans<<" "<<m-1<<"\n";
    }
    else{
        int ans=0;
        bool vis[100010];memset(vis,0,sizeof(vis));
        int tgt=0;
        for(int i=1;i<=m;++i){
            for(int j=1;j<=n;++j){
                if(a[j].l<=b[i]&&a[j].r>=b[i]){
                    vis[j]=1;
                }
            }
        }
        for(int i=1;i<=n;++i){
            ans+=vis[i];
            tgt=(tgt<<1)|vis[i];
        }
        cout<<ans<<" ";
        dfscase0(1,0);
        ans=1e9;
        for(int i=0;i<vcase0.size();++i){
            //cout<<vcase0[i].second<<' ';
            if(vcase0[i].second==tgt){
                ans=min(ans,vcase0[i].first);
            }
        }
        cout<<m-ans<<"\n";
    }
}

signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>T;
    while(T--){
        clear();
        solve();
    }
}
